package com.pcitc.app.model;

import com.pcitc.app.model.BaseObject;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import java.io.Serializable;

@Entity
@Table(name="TBL_USER_ROLE",schema="XZGD")
public class TblUserRole extends BaseObject implements Serializable {
    private Long urkid;
    private TblUser tblUser;
    private TblRole tblRole;

    @Id  @GeneratedValue(strategy = GenerationType.AUTO)    
    public Long getUrkid() {
        return this.urkid;
    }
    
    public void setUrkid(Long urkid) {
        this.urkid = urkid;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="USERID")
    public TblUser getTblUser() {
        return this.tblUser;
    }
    
    public void setTblUser(TblUser tblUser) {
        this.tblUser = tblUser;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="ROLEID")
    public TblRole getTblRole() {
        return this.tblRole;
    }
    
    public void setTblRole(TblRole tblRole) {
        this.tblRole = tblRole;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TblUserRole pojo = (TblUserRole) o;

        if (tblUser != null ? !tblUser.equals(pojo.tblUser) : pojo.tblUser != null) return false;
        if (tblRole != null ? !tblRole.equals(pojo.tblRole) : pojo.tblRole != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (tblUser != null ? tblUser.hashCode() : 0);
        result = 31 * result + (tblRole != null ? tblRole.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("urkid").append("='").append(getUrkid()).append("', ");
        sb.append("tblUser").append("='").append(getTblUser()).append("', ");
        sb.append("tblRole").append("='").append(getTblRole()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
